package weixin.core.controller;

import com.github.sd4324530.fastweixin.api.CustomAPI;
import com.github.sd4324530.fastweixin.api.entity.CustomAccount;
import com.github.sd4324530.fastweixin.api.enums.ResultType;
import com.github.sd4324530.fastweixin.api.response.GetCustomAccountsResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by lxb on 2016/4/7.
 */
@Controller
@RequestMapping("customer")
public class CustomController {
    private static final Logger LOG  = LoggerFactory.getLogger(CustomController.class);
    @Autowired
    private CustomAPI CustomAPI;

    @RequestMapping("getCustomer")
    @ResponseBody
    public GetCustomAccountsResponse getAllCustom() {
        GetCustomAccountsResponse customAccountList = CustomAPI.getCustomAccountList();
        if(customAccountList.getCustomAccountList().size()!=0){
            for (CustomAccount customAccount : customAccountList.getCustomAccountList()) {
                LOG.info("客服昵称为：" + customAccount.getNickName());
            }
            return customAccountList;
        }
        return null;

    }
    @RequestMapping("creaeteCustomer")
    @ResponseBody
    public String createCustomer(){
        CustomAccount account=new CustomAccount();
        account.setAccountName("lxb1@gh_8001b9b02b3f");
        account.setNickName("刘学兵1");
        ResultType resultType= CustomAPI.addCustomAccount(account);
        return "success";
    }
}
